// path：src/App.tsx

import { createBrowserHistory } from 'history';
import React from 'react';
import { Router, Switch, Route } from 'react-router';
import routeData from './route';
import NotFound from '@/components/Loading'
const history = createBrowserHistory();

const App: React.FC = () => {
  return (
    <Router history={history}>
      <Switch>
        {routeData.map((item: { path: '', exact: true, title: '', children: any, component: any }, index: any) => {
          return <Route
            exact={item.exact}
            key={index}
            path={item.path}
            render={(props) => {
              document.title = item.title
              return <item.component routes={item.children ? item.children : []} {...props} />
            }
            } />
        })}
        <Route component={NotFound} />
      </Switch>
    </Router>
  );
};

export default App;

